< previous page page_426 next page >

Page 426
In Chapter 18, "Proper Interface Design," you learned how to design the visual portion of your program in order to provide an appropriately usable and aesthetically pleasing interface for the users. This chapter continues that discussion to explore some of the design elements that you can use to give your programs a professional appearance.
Using Graphics
A typical user interface for an application consists of a menu, labels, text boxes, command buttons, and perhaps a few controls for specific pieces of data. However, without graphics, an otherwise functional interface can be quite boring and unintuitive. Graphics can be used to enhance the user interface in the following ways:
Highlighting specific information on the screen
Providing a different view of the information, such as using a graph
Providing a more intuitive link to the application's functions
The subject of design and use of graphics is large and complex. Obviously, then, this single chapter cannot cover all the bases. However, it provides you with enough information so that you can begin building a more visually pleasing user interface.
You can use graphics in two basic ways in VB: controls and methods. For example, you can draw a line on a form either by placing a Line control on the form or by using the Line method.
note.gif The Windows API also contains many graphics-related functions. See Chapter 20, "Accessing the Windows API," for information on accessing these functions. square.gif

Graphics controls work just like any other custom controls in that they have events and properties and can be drawn at designtime with the mouse. Graphics methods are functions you can call from within the VB language at runtime. Although you can think of graphics controls as objects placed on the form, graphics methods draw on the form itself.
Graphics Controls
Visual Basic's Toolbox includes several graphics controls. Some of these controls, such as the Line control, are simple controls intended to act as visual enhancements by themselves. Others, such as the PictureBox control, include a variety of properties and methods to allow extended functionality. Each of the VB graphics controls is discussed in the following sections.
Using the Line and Shape Controls
lscontrols.giflscontrols.gifThe Line and Shape controls provide the easiest means to add a graphic element to a form. You can draw the controls on the form at designtime and place them where you need them. During the execution of a program, these controls can be hidden or moved. Setting the appropriate property values in your code can change their colors.
As you would guess by its name, the Line control places a line on the form. You can control the width of the line, the line style, the color, and the position of the terminal points of the line through the control's properties. For example, start a new Standard EXE project and place a Line control on the form. Then enter the following code in the form's Resize event:

 
< previous page page_426 next page >